
#define WIN32_LEAN_AND_MEAN
#define DEBUG
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include "Map.h"
#include "../gfx/RenderEngine.h"
#include "../gfx/RenderableUnit.h"
#include "../shared/shared_types.h"
#include "../techdemo1/GameImplementation.h"
using namespace Putin;
using Putin::Map;
using Putin::Vec2i;
using micropather::MicroPather;

/**
 * Main application entry point
 */
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	TechDemo td;
	td.start();	
	
	//need to be created once (according to the singleton layout)
/*	RenderEngine* re = new RenderEngine();
	RenderEngine::instance().init();
	RenderEngine::instance().setCameraPosition( Vec3f( -100.0f, 100.0f, -100.0f ) );
	RenderEngine::instance().setCameraLookAt( Vec3f( 100.0f, 0.0f, 100.0f ) );

	RenderEngine::instance().loadMap( "putinterrain.cfg" );

	RenderableUnit* unit = new RenderableUnit();
	
	//Tanks normals and shit seems wierd, will see if it's fixable soon
	unit->setMesh( "tank.mesh" );
	unit->setMaterial( "Putin/tank" );
	unit->setId( "unit1" );
	//unit->addParticleEffect( "Putin/smoke" );
	unit->setPosition( Vec3f( 30.0f, 40.0f, 60.0f ) );

	RenderableUnit* unit2 = new RenderableUnit();
	unit2->setId( "unit2" );
	unit2->setMesh( "tank.mesh" );
	unit2->setMaterial( "Putin/tank" );
	unit2->addParticleEffect( "Putin/fire" );
	unit2->setPosition( Vec3f( 100.0f, 40.0f, 100.0f ) );

	std::vector< RenderableUnit* > unitVector;
	unitVector.push_back( unit );
	unitVector.push_back( unit2 );

	RenderEngine::instance().updateUnits( unitVector );

	RenderEngine::instance().startRendering();
	delete re;
*/

	/* Getting the heightmap, returns an array of floats w*h long.
	or just use: map->getHeight(x, y);
	*/
	/*Map *map = new Map();
	map->loadFromFile("testmap.gbm"); // a 256x256 testmap with some different heights, put inside working directory
	float* hm;
	hm = map->getHeightMap();
	float test = hm[1000];*/
	

	/*
	Map *map = new Map();
	map->loadFromFile("f:\\slask\\testmap.gbm");
	
	//float dist = map->LeastCostEstimate((void*)0,(void*)65);
	//std::vector<StateCost> costs;
	//map->AdjacentCost((void*)100, &costs);

	MicroPather pather(map);

	std::vector< void* > path;
	float totalCost;
	int p1x = map->getStartLocationX(0);
	int p1y = map->getStartLocationY(0);
	int p1 = p1y * map->getW() + p1x;
	int p2x = map->getStartLocationX(1);
	int p2y = map->getStartLocationY(1);
	int p2 = p2y * map->getW() + p2x;

	int result = pather.Solve((void*)p1, (void*)p2, &path, &totalCost );
	
	map->paintPath(path);
	map->saveToFile("f:\\slask\\changedmap.gbm");

	return 0;
	*/

	return 0;
}

